<template>
    <view class="thoughtsBook">
        <thought-item :content="item" v-for="(item, index) in thoughtList" :key="index"></thought-item>
	</view>
</template>

<script>
import thoughtItem from '../../../component/thoughtsItem/index';
// pages/thoughtsBook/index.js
import { fetchThoughts } from '../../../service/thoughts.service';
import { deleteThoughts } from '../../../service/thoughts.service';
export default {
    components: {
        thoughtItem
    },
    data() {
        return {
            openID: '',
            thoughtList: []
        };
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        const openID = options.openID;
        this.setData({
            openID
        });
        this.getThoughts(openID);
    },
    methods: {
        async getThoughts(openId) {
            const res = await fetchThoughts({
                openId
            });
            this.setData({
                thoughtList: res.data.data
            });
            console.log(res);
        },
		async deleteT() {
			const openID = this.openID; 
			const url = '/user/deleteSecret';
			console.log(this.thoughtList[0]);
			let resi;
			resi = await deleteThoughts(url, {
				content: this.thoughtList[0],
				openId: openID
			});
			console.log(resi);
			if (resi.data.message == 'success') {
				Notify({
					message: '删除成功',
					type: 'success',
					duration: 800
				});
			}
		}
	}
};
</script>
<style>
/* pages/thoughtsBook/index.wxss */

</style>
